package com.quectel.mobile.controller.partybuilding;

import com.quectel.constant.global.SystemConstants;
import com.quectel.core.module.partybuilding.dto.PartyBuildingServicesDto;
import com.quectel.core.module.partybuilding.service.PartyBuildingServicesService;
import com.quectel.mobile.controller.BaseController;
import com.quectel.mobile.util.SessionHolder;
import com.quectel.util.common.Response;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 在这里编写说明
 *
 * @author: bob
 * @email: bob.yu@quectel.com
 * @date: 2023-06-13 9:11:10
 */
@RestController
@RequestMapping("partyBuildingServices")
@Tag(name = "PartyBuildingServicesController", description = "党建服务管理相关api")
public class PartyBuildingServicesController extends BaseController {

    @DubboReference
    private PartyBuildingServicesService partyBuildingServicesService;

    @GetMapping("queryInfoByCategory")
    @Operation(summary = "移动端党建服务数据查询")
    public Response<PartyBuildingServicesDto> queryInfoByCategory(
            @Parameter(description = "1.入党申请 2.党组织申请") @RequestParam(required = false)Byte category) {

        Long tenantId = SessionHolder.getLoginMobileUserSession().getTenantId();

        PartyBuildingServicesDto dbValue = partyBuildingServicesService.selectOneByCategory(tenantId, category);
        if (dbValue ==null){
            return Response.error(SystemConstants.ILLEGAL_MSG);
        }

        return Response.<PartyBuildingServicesDto>ok().wrap(dbValue);
    }

}
